---
title: "MongoDB"
sidebarTitle: "MongoDB Provider"
description: "MongoDB Provider is a provider used to query MongoDB databases"
---

## Inputs

The `query` function of `MongoDBProvider` takes the following arguments:

- `query` (str): A string containing the query to be executed against the MongoDB database.
- `single_row` (bool, optional): If `True`, the function will return only the first result.

## Outputs

The `query` function returns either a `list` or a `tuple` of results, depending on whether `single_row` was set to `True` or not. If `single_row` was `True`, then the function returns a single result.

## Authentication Parameters

The following authentication parameters are used to connect to the MongoDB database:

- `host` (str): The MongoDB connection URI. It can be a full uri with database, authSource, user, pass; or just hostip.
- `username` (str, optional): The MongoDB username.
- `password` (str, optional): The MongoDB password.
- `database` (str, optional): The name of the MongoDB database.
- `authSource` (str, optional): The name of the database against which authentication needs to be done.
- `additional_options` (str, optional): Additinal options to be passed to MongoClient as kwargs.

## Connecting with the Provider

In order to connect to the MongoDB database, you can use either a connection URI or individual parameters. Here's how you can provide authentication information:

1. If using a connection URI, provide the `host` parameter with the MongoDB connection string.
2. If using individual parameters, provide the following:
   - `username`: MongoDB username.
   - `password`: MongoDB password.
   - `host`: MongoDB hostname.
   - `database`: MongoDB database name.
   - `authSource`: MongoDB database name.

## Notes

- Ensure that the provided user has the necessary privileges to execute queries on the specified MongoDB database.

## Useful Links

- [MongoDB Documentation](https://docs.mongodb.com/)
